﻿using Common.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Infrastructure.Repository
{
    public interface IBaseRepository<T> where T : class
    {
        /// <summary>
        /// 获取全部数据
        /// </summary>
        /// <returns>返回集合</returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回受影响行数</returns>
        int Add(T entity);
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回受影响行数</returns>
        int Update(T entity);
        /// <summary>
        /// 批量新增数据
        /// </summary>
        /// <param name="entities">实体</param>
        /// <returns>返回受影响行数</returns>
        int AddRange(IEnumerable<T> entities);
        /// <summary>
        /// 批量修改数据
        /// </summary>
        /// <param name="entities">实体</param>
        /// <returns>返回受影响行数</returns>
        int UpdateRange(IEnumerable<T> entities);
        int Delete(T entity);
    }
}
